package com.qunduikj.sjb.sdk.crypt;

import com.litesuits.android.log.Log;
import com.litesuits.http.data.NameValuePair;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author MaTianyu on 2015-05-05
 */
public class Creator {

    private static final String TAG = Creator.class.getSimpleName();

    public static List<NameValuePair> build(Map<String, String> map) throws Exception {
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        if (map != null) {
            StringBuilder builder = new StringBuilder();
            for (Map.Entry<String, String> entry : map.entrySet()) {
                builder.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
            }
            String value = builder.toString();
            String encrypt = Des3Util.encode(value);
            formparams.add(new NameValuePair("value", encrypt));
            Log.i(TAG, "加密前：" + value);
            Log.i(TAG, "加密后：" + encrypt);
        }
        formparams.add(new NameValuePair("appID", Constant.APPID));
        return formparams;
    }

    public static void main(String[] ss) {
        String s = "type=1&";
        try {
            //            System.out.println("加密前：" + s);
            //            System.out.println("加密后：" + Des3Util.encode(s));
            //            System.out.println("chu后：" + Des3Util.decode(Des3Util.encode(s)));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
